<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <title>转诊-51问医生</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <script src="{{url('/js/rem.js')}}"></script>
    <script src="{{url('/js/jquery.min.js')}}" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="{{url('./css/base.css')}}"/>
    <link rel="stylesheet" type="text/css" href="{{url('./css/page.css')}}"/>
    <link rel="stylesheet" type="text/css" href="{{url('./css/all.css')}}"/>
    <link rel="stylesheet" type="text/css" href="{{url('./css/loaders.min.css')}}"/>
    <link rel="stylesheet" type="text/css" href="{{url('./css/loading.css')}}"/>
    <script type="text/javascript" src="{{url('./js/jquery-1.8.3.min.js')}}" ></script>
    <script src="{{url('./js/others.js')}}"></script>
    <script src="{{url('./js/swiper.jquery.min.js')}}"></script>

    <link rel="stylesheet" href="{{url('css/font-awesome.min.css')}}">
    <link rel="stylesheet" href="{{url('/css/foxui.css')}}">
    <link rel="stylesheet" href="{{url('/css/foxui.theme.css')}}">
    <script type="text/javascript" src="{{url('js/foxui.js')}}"></script>
    <link rel="stylesheet" href="{{url('css/weui.min.css')}}">
    <link rel="stylesheet" href="{{url('css/jquery-weui.min.css')}}">

    <!-- Noty 提示框的js集成 -->
    <script src="{{ url('vendor/noty-2.2.9/packaged/jquery.noty.packaged.js') }}"></script>
    <script src="{{ url('vendor/noty-2.2.9/themes/bootstrap.js') }}"></script>
    <script src="{{ url('vendor/noty-2.2.9/options.js') }}"></script>
    <style>
        body{
            background-color: #f9f5f5;
        }
        .change-doctor{
            width: 1.8rem;
            height: 0.7rem;
            border: 1px solid #c7712b;
            color: #c7712b;
        }
        .user-info{
            width: 100%;
            height: 4.4rem;
            background-color: #ffffff;
        }
        .user-jiuzhen{
            width: 100%;
            height: 100%;
            margin-top: 0.25rem;
            position: relative;
            border-bottom: 1px solid #efeeec;
        }
        .user-info-refer{
            font-size: 0.38rem;
            color: #bfbfb9;
        }
    </style>
</head>
{{--<!--loading页开始-->--}}
{{--<div class="loading">--}}
    {{--<div class="loader">--}}
        {{--<div class="loader-inner pacman">--}}
            {{--<div></div>--}}
            {{--<div></div>--}}
            {{--<div></div>--}}
            {{--<div></div>--}}
            {{--<div></div>--}}
        {{--</div>--}}
    {{--</div>--}}
{{--</div>--}}
{{--<!--loading页结束-->--}}
<body>
<header class="mui-bar mui-bar-nav report-header box-s" id="header" style="background-color: #000000;padding: 3% 3%">
    <a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl" style="color: white"></i></a>
    <p style="color: #FFFFFF">转诊信息</p>
</header>
<!-- 患者信息部分 -->
<div>
    <div class="user-info" style="position: relative;border-bottom: 1px solid #efeeec">
        <div style="position: absolute; width: 2rem;height: 2rem;top: 0.7rem;left: 0.7rem;">
            <img style="width: 100%;border-radius: 1rem;border: 0.1rem solid white" src="@if($that_userinfo){{route('Api.Image.Show',['id'=>$that_userinfo->portrait_id])}}@else{{route('Api.Image.Show',['id'=>0])}}@endif">
        </div>
        <div style="position:absolute;left: 3.4rem;top: 0.7rem;">
            <p style="color: #525252">{{$that_userinfo->realname}}</p>
            <ul class="user-info-refer">
                <li>就诊地点：@if($hospital){{$hospital->name}}@endif</li>
                <li>手&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机：{{$that_userinfo->phone}}</li>
                <li>性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：@if($that_userinfo->sexual == 0)未知 @elseif($that_userinfo->sexual == 1)男@else女@endif</li>
                <li>出生年月：{{$that_userinfo->birthday}}</li>
            </ul>
        </div>
    </div>

    <div class="user-jiuzhen">
        <div style="position: absolute;width: 100%;height: 15rem;background-color: white">
            <div style="margin-top: 0.2rem;margin-left: 0.7rem;color: #a59e9e">转诊信息录入</div>
            <div class="weui-cells" style="width: 100%">
                <div class="weui-cell weui-cell_select weui-cell_select-after" style="padding-left: 24px;">
                    <div class="weui-cell__hd">
                        <label for="" class="weui-label">选择医院</label>
                    </div>
                    <div class="weui-cell__bd">
                        <select class="weui-select" name="hospital_list" id="hospital_list">
                            @if(count($all_hospital) > 0)
                                @foreach($all_hospital as $theHospital)
                            <option value="{{$theHospital->id}}">{{$theHospital->name}}</option>
                                @endforeach
                            @endif
                        </select>
                    </div>
                </div>
                <div class="weui-cell weui-cell_select weui-cell_select-after" style="padding-left: 24px;">
                    <div class="weui-cell__hd">
                        <label for="" class="weui-label">转入科室</label>
                    </div>
                    <div class="weui-cell__bd">
                        <select class="weui-select" name="dep" id="dep_list">
                            <option value="0">请选择科室</option>
                        </select>
                    </div>
                </div>
                <div class="weui-cell weui-cell_select weui-cell_select-after" style="padding-left: 24px;">
                    <div class="weui-cell__hd">
                        <label for="" class="weui-label">接诊医生</label>
                    </div>
                    <div class="weui-cell__bd">
                        <select class="weui-select" name="doctor" id="doctor_list">
                            <option value="0">请选择医生</option>
                        </select>
                    </div>
                </div>

                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">病人姓名</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" id="realname" placeholder="请输入病人姓名" value="{{$that_userinfo->realname}}">
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd"><label class="weui-label">联系方式</label></div>
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="number" id="phone" placeholder="请输入病人联系方式" value="{{$that_userinfo->phone}}">
                    </div>
                </div>
            </div>
            <div style="height: 0.5rem;width: 100%"></div>
            <div class="weui-cells__title" style="color: #060606;font-size: 17px;margin-left: 9px">病人诊断</div>
            <div class="weui-cells">
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <input class="weui-input" type="text" placeholder="请输入病人诊断信息" id="desc">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div style="width: 100%;height: 1.4rem;position: fixed;bottom: 0;z-index: 10">
        <input type="hidden" id="user_id" value="{{$that_user->id}}" />
        <button style="width: 100%;height: 100%;background-color: #da9c13;color: white;border: none" id="btn_send">提交</button>
    </div>
</div>
</div>
<!-- body 最后 -->
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script src="{{url('js/jquery-weui.min.js')}}"></script>
<script>
    $(function () {
        <!-- 医院联动查询 -->
        $('#hospital_list').change(function(){
            var id = $('#hospital_list option:selected').val();
            if(parseInt(id) != 0){
                $.ajax({
                    url:"{{route('Api.Doctor.getDepartmentByHospitalId')}}?id="+id,
                    type:"get",
                    dataType:"json",
                    success:function (obj) {
                        if(obj.level == 'success'){
                            appendDepartmen(obj.data);
                        }else {
                            noty({'type':'error','text':obj.message,timeout:600});
                        }
                    },
                    error:function (obj) {
                        console.log(obj);
                    }
                });
            }
        });

        //写入部门
        function appendDepartmen(data) {
            $('#dep_list').empty();
            $('#dep_list').append('<option value="0" selected>请选择科室</option>');
            if(data.length > 0){
                for(var i = 0;i < data.length;i++){
                    var htmlElent = '<option value="'+data[i].id+'">'+data[i].dep_name+'</option>';
                    $('#dep_list').append(htmlElent);
                }
            }
        }

        <!-- 科室联动查询 -->
        $('#dep_list').change(function(){
            var id = $('#dep_list option:selected').val();
            if(parseInt(id) != 0){
                $.ajax({
                    url:"{{route('Api.Doctor.getDoctorByDepId')}}?id="+id,
                    type:"get",
                    dataType:"json",
                    success:function (obj) {
                        if(obj.level == 'success'){
                            appendDoctor(obj.data);
                        }else {
                            noty({'type':'error','text':obj.message,timeout:600});
                        }
                    },
                    error:function (obj) {
                        console.log(obj);
                    }
                });
            }
        });
        
        function appendDoctor(data) {
            $('#doctor_list').empty();
            if(data.length > 0){
                for(var i = 0;i < data.length;i++){
                    var htmlElent = '<option value="'+data[i].id+'">'+data[i].doc_name+'</option>';
                    $('#doctor_list').append(htmlElent);
                }
            }else {
                $('#doctor_list').append('<option value="0" selected>请选择医生</option>');
            }
        }

        $(document).on("click",'#btn_send',function () {
            var user_id = $('#user_id').val();
            var doc_id  = $('#doctor_list option:selected').val();
            var desc    = $('#desc').val();
            var phone   = $('#phone').val();
            var realname = $('#realname').val();
            $.ajax({
                url:"{{route('Api.Doctor.buildReferral')}}",
                type:"post",
                dataType:"json",
                data:{user_id:user_id,doc_id:doc_id,desc:desc,phone:phone,realname:realname},
                success:function (obj) {
                    if(obj.level == 'success'){
                        $.confirm("是否需要对方医院急诊车接送？", "提交成功", function() {
                            window.location.href="{{route('M.Doctor.hospitalList')}}";
                        }, function() {
                            $.toast("不需要!");
                        });
                    }else {
                        noty({'type':'error','text':obj.message,timeout:600});
                    }
                },
                error:function (obj) {
                    console.log(obj);
                }
            });
        });
    });
</script>
</body>
</html>
